<template>
    <div class="fen_lei">
        <div class="title">
            <img @click="go_back" class="fan_hui" src="../lmx/image/return.png" alt="">
            <span>分类</span>
        </div>
        <div class="xia">
            <div ref="left" class="left">
                <div class="main">
                    <div @click="xxx(index)" class="kuai" v-for="item,index in class_list"  :class="active!=index?'kuai':'hongkuai'">
                        <div class="tiao"  v-if="active==index"></div>
                        <div class="class" :class="active!=index?'class':'yanse'" >{{item}}</div>
                    </div>
                </div>
            </div>
            <div ref="right" class="right">
                <div class="main">
                    <div class="one_hang" v-for="(item,index) in hang_list" :key="index">
                    <img class="tu" :src="item.url" alt="">
                    <span class="zi">{{item.zi}}</span>
                </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from "vue-router"
const router = useRouter()
const left = ref()
const active = ref(0);
var class_list  = ['纸艺','手绘','书法','结绳','编织','刺绣','纸艺','手绘','书法','结绳','编织','刺绣','书法','结绳','编织','刺绣','书法','结绳','编织','刺绣','书法','结绳','编织','刺绣',]
var hang_list = [
    {
        url:new URL ('../lmx/image/11.jpeg',import.meta.url).href,
        zi:'云云云云云云云云云云云云云云云云云云云云云云云云云云云云云云云云'
    },
    {
        url:new URL ('../lmx/image/22.jpg',import.meta.url).href,
        zi:'云云云云云云云云云云云云云云云云云云'
    },
    {
        url:new URL ('../lmx/image/33.jpeg',import.meta.url).href,
        zi:'云云云云云云云云云云云云云云云云云云'
    },
]
//计算滚动高度
onMounted(() => {
    var h = document.documentElement.clientHeight || document.body.clientHeight
    var vdaH = h - 40 + 'px'
    const boxLeft = left.value
    boxLeft.style.height = vdaH
})
function go_back() {
    router.go(-1)
}
function xxx (i){
    active.value = i
    console.log(class_list[i])
    console.log(active.value)
}
</script>

<style scoped>
* {
    padding: 0;
    margin: 0;
}
.fen_lei {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.title {
    width: 100%;
    height: 40px;
    /* background-color: blue; */
    position: relative;
    margin: 0 auto;
}
.fan_hui {
    width: 25px;
    height: 25px;
    margin-top: 7.5px;
    margin-bottom: 7.5px;
    margin-left: 5px;
}
.title>span {
    position: absolute;
    left: 50%;
    top: 50%;
    margin-top: -10.4px;
    margin-left: -16px;
}
.xia {
    width: 100%;
    flex: 1;
    /* background-color: aqua; */
    display: flex;
    justify-content: space-between;
}
.left {
    width: 80px;
    overflow: scroll;
}
.left>.main {
    width: 80px;
    /* height: 300px; */
    /* background-color: blueviolet; */
    display: flex;
    flex-direction: column;
}
.kuai {
    width: 100%;
    height: 40px;
    background-color: #f7f8fa;
    position: relative;
    margin: 0 auto;
}
.hongkuai{
    background-color: #fffefe;
}
.tiao {
    width: 3px;
    height: 12px;
    background-color: #f25348;
    position: absolute;
    top: 50%;
    margin-top: -6px;
}
.class {
    position: absolute;
    left: 50%;
    top: 50%;
    margin-top: -10.4px;
    margin-left: -16px;
    color: #9d9c9c;
}
.yanse{
    color:#f3837b !important;
}
.right {
    width: 286px;
    /* height: 500px; */
    /* background-color: brown; */
    overflow: scroll;
}
.right>.main{
    width: 100%;
    /* height: 180%; */
    /* background-color: aquamarine; */
    display: flex;
    flex-direction: column;
}
.one_hang{
    width: 100%;
    height: 65px;
    /* background-color: blueviolet; */
    margin-top: 10px;
    display: flex;
    /* justify-content: space-between; */
    align-items: center;
}
.tu{
    width: 130px;
    height: 100%;
    border-radius: 5px;
    /* background-color: blanchedalmond; */
}
.zi{
    width: 160px;
    height: 100%;
    margin-left: 14px;
    border-bottom: 1px solid #dcdee0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp:3;
    word-break: break-all;
    -webkit-box-orient: vertical;
    
}
</style>